// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
// Copyright (c) 2015-2020 Andrey Antukh <niwi@niwi.nz>
// Copyright (c) 2015-2020 Juan de la Cruz <delacruzgarciajuan@gmail.com>

.element-list-body {
  align-items: center;
  display: flex;
  height: 32px;
  padding: $size-1 $size-2;
  transition: none;
  width: 100%;

  svg {
    fill: $color-gray-20;
    height: 13px;
    flex-shrink: 0;
    margin-right: 8px;
    width: 13px;
  }

  &.group {
    &.open {
      .toggle-content {
        flex-shrink: 0;

        svg {
          transform: rotate(270deg);
        }
      }
    }
  }

  &:hover {
    background-color: $color-primary;

    svg {
      fill: $color-gray-60 !important;
    }

    .element-icon,
    .element-actions {
      svg {
        fill: $color-gray-60;
      }
    }

    .element-actions > * {
      display: flex;
    }

    span {
      color: $color-gray-60;
    }

    .toggle-content {
      svg {
        fill: $color-gray-60;
      }
    }
  }

  &.selected {
    background-color: $color-gray-60;

    svg {
      fill: $color-primary;
    }

    .element-icon {
      svg {
        fill: $color-primary;
      }
    }

    span {
      color: $color-primary;
    }

    &:hover {
      background-color: $color-primary;

      .element-icon,
      .element-actions {
        svg {
          fill: $color-gray-60;
        }
      }

      .element-name {
        color: $color-gray-60;
      }
    }
  }

  &.drag-top {
    border-top: 40px solid $color-gray-60 !important;
  }

  &.drag-bottom {
    border-bottom: 40px solid $color-gray-60 !important;
  }

  &.drag-inside {
    border: 2px solid $color-primary !important;
  }
}

.element-list li.sticky {
  > :first-child {
    position: sticky;
    top: 0px;
    background-color: $color-gray-50;
    z-index: 1;
    &.selected {
      background-color: #1f1f1f;
    }
    &:hover {
      background-color: #31efb8;
    }
  }
}

.element-list li.component {
  .element-list-body {
    span.element-name {
      color: $color-component;
    }

    svg {
      fill: $color-component;
    }

    &.selected {
      span.element-name {
        color: $color-component-highlight;
      }

      svg {
        fill: $color-component-highlight;
      }
    }

    &:hover {
      background-color: $color-component-highlight;

      span.element-name {
        color: $color-gray-60;
      }

      svg {
        fill: $color-gray-60;
      }
    }
  }
}

.element-list li.masked > .element-children > li {
  &:first-child {
    position: relative;

    &::before {
      content: " ";
      border-right: 1px solid $color-gray-40;
      border-top: 1px solid $color-gray-40;
      position: absolute;
      width: 6px;
      height: 6px;
      transform: rotate(-45deg);
      top: -1px;
      left: -4px;
    }

    &.sticky {
      margin-top: 32px;
    }
  }

  &:last-child {
    border-left: none;
    position: relative;

    &::after {
      content: " ";
      border-left: 1px solid $color-gray-40;
      border-bottom: 1px solid $color-gray-40;
      height: 1rem;
      width: 0.3rem;
      position: absolute;
      top: 0;
      left: 0;
    }
  }
}

.element-icon {
  svg {
    fill: $color-gray-30;
  }
}

input.element-name {
  max-width: 75%;
}

span.element-name {
  color: $color-gray-20;
  display: block;
  font-size: $fs12;
  max-width: 75%;
  min-width: 40px;
  min-height: 16px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.element-actions {
  display: flex;
  flex-shrink: 0;
  height: 14px;
  margin-left: auto;
  position: relative;
  width: 32px;
  right: 20px;

  &.is-parent {
    right: 0;
  }

  svg {
    height: 13px;
    width: 13px;
  }

  > * {
    display: none;
  }

  .toggle-element,
  .block-element {
    left: 0;
    position: absolute;
    top: 0;

    &.selected {
      display: flex;

      svg {
        fill: $color-gray-20;
      }
    }
  }
}

.block-element {
  left: 18px !important;

  svg {
    fill: $color-gray-30;
  }
}

.toggle-content {
  margin-left: 8px;
  width: 12px;

  svg {
    fill: $color-gray-20;
    transform: rotate(90deg);
    width: 10px;
  }

  &.inverse {
    svg {
      transform: rotate(270deg);
    }
  }

  &:hover {
    svg {
      fill: $color-gray-60;
    }
  }
}

.icon-layer {
  > svg {
    background-color: rgba(255, 255, 255, 0.6);
    border-radius: $br-small;
    flex-shrink: 0;
    fill: $color-black !important;
    padding: 1px;
  }
}

#layers {
  .tool-window-bar {
    display: flex;
    justify-content: space-between;
    height: 32px;
    margin-top: 8px;

    &.search {
      .search-box {
        border: 1px solid $color-primary;
        border-radius: 4px;
        height: 32px;
        width: 100%;
        display: flex;
        align-items: center;
        input {
          border: 0;
          width: 100%;
          background-color: $color-gray-50;
          color: $color-white;
          font-size: 12px;
          height: 16px;
        }
        span {
          height: 16px;
          overflow: hidden;
        }
        .filter,
        .clear {
          width: 35px;
          &.active {
            svg {
              fill: $color-primary;
            }
          }
        }
      }
    }

    svg {
      width: 16px;
      height: 16px;
      margin: 0 2px 0 5px;
      cursor: pointer;
    }
  }
}
.active-filters {
  margin-top: 5px;
  line-height: 26px;
  font-size: 11px;
  margin: 0 0.5rem;
  span {
    background-color: $color-primary;
    color: $color-black;
    padding: 3px 5px;
    margin: 0 2px;
    border-radius: 4px;
    cursor: pointer;
    svg {
      width: 7px;
      height: 7px;
      vertical-align: middle;
      margin-left: 5px;
    }
  }
}

.filters-container {
  position: absolute;
  display: flex;
  flex-direction: column;
  top: 40px;
  left: 8px;
  background-color: $color-white;
  color: $color-gray-50;
  border-radius: 4px;
  span {
    padding: 10px 20px 10px 10px;
    border-radius: 4px;
    svg {
      width: 16px;
      height: 16px;
      margin-right: 10px;
      vertical-align: middle;
      fill: $color-gray-30;
    }

    &:hover {
      background-color: $color-primary-lighter;
    }
  }
}
